/*
 * Copyright (c) 2006-2007 Silicon Graphics, Inc.
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#ifndef __DFS_FILESTREAM_H__
#define __DFS_FILESTREAM_H__

struct dfs_mount;
struct dfs_inode;
struct dfs_perag;
struct dfs_bmalloca;

#ifdef DFS_FILESTREAMS_TRACE
#define DFS_FSTRM_KTRACE_INFO		1
#define DFS_FSTRM_KTRACE_AGSCAN		2
#define DFS_FSTRM_KTRACE_AGPICK1	3
#define DFS_FSTRM_KTRACE_AGPICK2	4
#define DFS_FSTRM_KTRACE_UPDATE		5
#define DFS_FSTRM_KTRACE_FREE		6
#define	DFS_FSTRM_KTRACE_ITEM_LOOKUP	7
#define	DFS_FSTRM_KTRACE_ASSOCIATE	8
#define	DFS_FSTRM_KTRACE_MOVEAG		9
#define	DFS_FSTRM_KTRACE_ORPHAN		10

#define DFS_FSTRM_KTRACE_SIZE	16384
extern ktrace_t *dfs_filestreams_trace_buf;

#endif

/* allocation selection flags */
typedef enum dfs_fstrm_alloc {
	DFS_PICK_USERDATA = 1,
	DFS_PICK_LOWSPACE = 2,
} dfs_fstrm_alloc_t;

/* prototypes for filestream.c */
int dfs_filestream_init(void);
void dfs_filestream_uninit(void);
int dfs_filestream_mount(struct dfs_mount *mp);
void dfs_filestream_unmount(struct dfs_mount *mp);
dfs_agnumber_t dfs_filestream_lookup_ag(struct dfs_inode *ip);
int dfs_filestream_associate(struct dfs_inode *dip, struct dfs_inode *ip);
void dfs_filestream_deassociate(struct dfs_inode *ip);
int dfs_filestream_new_ag(struct dfs_bmalloca *ap, dfs_agnumber_t *agp);


/* filestreams for the inode? */
static inline int
dfs_inode_is_filestream(
	struct dfs_inode	*ip)
{
	return (ip->i_mount->m_flags & DFS_MOUNT_FILESTREAMS) ||
		dfs_iflags_test(ip, DFS_IFILESTREAM) ||
		(ip->i_d.di_flags & DFS_DIFLAG_FILESTREAM);
}

#endif /* __DFS_FILESTREAM_H__ */
